package com.workcenter.entity;

import com.workcenter.entity.model.ESearchCondition;
import com.workcenter.entity.model.EUser;

import android.app.Application;

public class Session extends Application
{
   private static Session instance=null;
   public static synchronized Session getInstance()
   {
	  if(instance==null)
		 instance=new Session();
	  return instance;
   }
   
   @Override
   public void onCreate()
   {
	  super.onCreate();
	  instance=(Session)getApplicationContext();
   }

   private boolean IsDEBUG = false;
   private EUser userInfo;
   private ESearchCondition searchCondition;
     
   
   public ESearchCondition getSearchCondition()
   {
      return searchCondition;
   }
   public void setSearchCondition(ESearchCondition searchCondition)
   {
      this.searchCondition = searchCondition;
   }
   public void CleanSearchCondition()
   {
	  searchCondition=null;
   }

   public EUser getUserInfo()
   {
      return userInfo;
   }
   public void setUserInfo(EUser userinfo)
   {
      this.userInfo = userinfo;
   }
 
   public boolean IsDEBUG()
   {
	  return IsDEBUG;
   }

   public void setDEBUG()
   {
	  IsDEBUG = true;
   }


   public boolean isLogin()
   {
	  if (userInfo == null || userInfo.getLoginName()==null||userInfo.getLoginName().equals(""))
	  {
		 return false;
	  }
	  else
	  {
		 return true;
	  }
   }
   
   public void Logout()
   {
      userInfo=null;

	  if(instance!=null)
	  {
		 instance=null;
	  }
   }

}
